package com.example.hello;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.widget.TextView;

public class ShowMessageActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_show_message);
        
        Intent intent = getIntent();
        String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);
        
        TextView text = (TextView) findViewById(R.id.show_message_text);
        text.setText(message);

        TextView length = (TextView) findViewById(R.id.show_message_length);
        length.setText(message.length() + "");
        
    }
    
    @Override 
    protected void onStop(){
        TextView text = (TextView) findViewById(R.id.show_message_text);
        text.setText(R.string.hello_world);

        TextView length = (TextView) findViewById(R.id.show_message_length);
        length.setText(R.string.empty_message_length);

        super.onStop();
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.show_message, menu);
        return true;
    }

}
